﻿Public Class fCentroSuministrador
    Dim daCentroSumi As lbGlobalcom.dsComprasTableAdapters.COM_CENTROSUMITableAdapter
   
    Private Sub btnCargarCentroSumi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCargarCentroSumi.Click
        Try
            If Me.DsCompras.COM_CENTROSUMI.GetChanges() IsNot Nothing Then
                COM_CENTROSUMIBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    COM_CENTROSUMIBindingNavigatorSaveItem.PerformClick()
                End If
            End If
            daCentroSumi.Fill(DsCompras.COM_CENTROSUMI)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub fCentroSuministrador_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If Me.DsCompras.COM_CENTROSUMI.GetChanges() IsNot Nothing Then
                COM_CENTROSUMIBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    COM_CENTROSUMIBindingNavigatorSaveItem.PerformClick()
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub


    Private Sub fCentroSuministrador_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            daCentroSumi = New lbGlobalcom.dsComprasTableAdapters.COM_CENTROSUMITableAdapter
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub COM_CENTROSUMIBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles COM_CENTROSUMIBindingNavigatorSaveItem.Click
        Try
            Validate()
            COM_CENTROSUMIBindingSource.EndEdit()
            daCentroSumi.Update(DsCompras.COM_CENTROSUMI)
            MessageBox.Show("Se salvarón registros con exito", "Salva Registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub COM_CENTROSUMIDataGridView_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles COM_CENTROSUMIDataGridView.DataError
        MessageBox.Show(e.Exception.Message)
    End Sub

    Private Sub COM_CENTROSUMIDataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles COM_CENTROSUMIDataGridView.UserDeletedRow
        Try
            daCentroSumi.Update(DsCompras.COM_CENTROSUMI)
            MessageBox.Show("Registro borrado con exito", "Elimina registro", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub COM_CENTROSUMIDataGridView_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles COM_CENTROSUMIDataGridView.UserDeletingRow
        If MessageBox.Show("Desea borrar el registro", "Elimina registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
            e.Cancel = True
        End If
    End Sub

    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        If MessageBox.Show("Desea borrar el registro", "Elimina registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            COM_CENTROSUMIBindingSource.Remove(COM_CENTROSUMIBindingSource.Current)
            COM_CENTROSUMIBindingNavigatorSaveItem.PerformClick()
        End If
    End Sub
End Class